<?php

namespace common\models\base;

use Yii;

/**
 * This is the model class for table "{{%che300_cm_vin_bind}}".
 *
 * @property int $id
 * @property int $che300_model_id
 * @property string $vin
 *
 * @property Che300CarModel $che300Model
 */
class Che300CmVinBind extends \yii\db\ActiveRecord
{
    /**
     * {@inheritdoc}
     */
    public static function tableName()
    {
        return '{{%che300_cm_vin_bind}}';
    }

    /**
     * {@inheritdoc}
     */
    public function rules()
    {
        return [
            [['che300_model_id', 'vin'], 'required'],
            [['che300_model_id'], 'integer'],
            [['vin'], 'string', 'max' => 20],
            [['che300_model_id'], 'exist', 'skipOnError' => true, 'targetClass' => Che300CarModel::className(), 'targetAttribute' => ['che300_model_id' => 'model_id']],
        ];
    }

    /**
     * {@inheritdoc}
     */
    public function attributeLabels()
    {
        return [
            'id' => Yii::t('app', 'ID'),
            'che300_model_id' => Yii::t('app', 'Che300 Model ID'),
            'vin' => Yii::t('app', 'Vin'),
        ];
    }

    /**
     * @return \yii\db\ActiveQuery
     */
    public function getChe300Model()
    {
        return $this->hasOne(Che300CarModel::className(), ['model_id' => 'che300_model_id']);
    }
}
